package com.ruoyi.system.mq;
import com.ruoyi.common.constant.FeeUserMqConstants;
import com.ruoyi.common.core.domain.entity.SysFeeUser;
import com.ruoyi.system.service.ISysFeeUserService;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class SysFeeUserlListener {

    @Autowired
    private ISysFeeUserService sysFeeUserService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = FeeUserMqConstants.INSERT_QUEUE_NAME),
            exchange = @Exchange(name = FeeUserMqConstants.EXCHANGE_NAME, type = ExchangeTypes.TOPIC),
            key = FeeUserMqConstants.INSERT_KEY
    ))
    public void listenHotelInsert(SysFeeUser sysFeeUser) throws IOException {
        // 新增
        System.out.println("新增:"+sysFeeUser.getUserId());
        sysFeeUserService.saveEsById(sysFeeUser);
    }
}
